package com.example.demo;

public class Supermarket {
    public static void main(String[] args) {
        int appleKg = 5;  //5斤苹果
        int strawberryKg = 3;  //3今草莓
        int mangoKg = 2;  //2斤苹果

        //A
        System.out.println("顾客A的总价：" + calculateTotalForCustomerA(appleKg, strawberryKg));
        //B
        System.out.println("顾客B的总价：" + calculateTotalForCustomerB(appleKg, strawberryKg, mangoKg));
        //C
        System.out.println("顾客C的总价：" + calculateTotalForCustomerC(appleKg, strawberryKg, mangoKg));
        //D
        System.out.println("顾客D的总价：" + calculateTotalForCustomerD(appleKg, strawberryKg, mangoKg));
    }

    // 定义水果价格
    private static final int APPLE_PRICE = 8;  // 苹果每斤价格
    private static final int STRAWBERRY_PRICE = 13;  // 草莓每斤价格
    private static final int MANGO_PRICE = 20;  // 芒果每斤价格

    //1题
    public static int calculateTotalForCustomerA(int appleKg, int strawberryKg) {
        return appleKg * APPLE_PRICE + strawberryKg * STRAWBERRY_PRICE;
    }

    //2题
    public static int calculateTotalForCustomerB(int appleKg, int strawberryKg, int mangoKg) {
        return appleKg * APPLE_PRICE + strawberryKg * STRAWBERRY_PRICE + mangoKg * MANGO_PRICE;
    }

    //3题
    public static double calculateTotalForCustomerC(int appleKg, int strawberryKg, int mangoKg) {
        double strawberryPriceWithDiscount = STRAWBERRY_PRICE * 0.8;
        return appleKg * APPLE_PRICE + strawberryKg * strawberryPriceWithDiscount + mangoKg * MANGO_PRICE;
    }

    //4题
    public static double calculateTotalForCustomerD(int appleKg, int strawberryKg, int mangoKg) {
        double total = calculateTotalForCustomerC(appleKg, strawberryKg, mangoKg);
        if (total >= 100) {
            total -= 10;
        }
        return total;
    }

}